package com.easykoo.web.tag;

import javax.servlet.jsp.tagext.TagSupport;

public abstract class BaseTag extends TagSupport{

    public void appendAttr(StringBuffer sb) {

        if (isNotBlank(getStyle())) {
            sb.append(" style=\"" + getStyle() + "\" ");
        }
        if (isNotBlank(getStyleClass())) {
            sb.append(" class=\"" + getStyleClass() + "\" ");
        }
        if (isNotBlank(getBackground())) {
            sb.append(" background=\"" + getBackground() + "\" ");
        }
        if (isNotBlank(getWidth())) {
            sb.append(" width=\"" + getWidth() + "\" ");
        }
        if (isNotBlank(getHeight())) {
            sb.append(" height=\"" + getHeight() + "\" ");
        }
        if (isNotBlank(getId())) {
            sb.append(" id=\"" + getId() + "\" ");
        }
        if (isNotBlank(getBgcolor())) {
            sb.append(" bgcolor=\"" + getBgcolor() + "\" ");
        }
        if (isNotBlank(getFont())) {
            sb.append(" font=\"" + getFont() + "\" ");
        }
    }

    public static boolean isBlank(String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if ((Character.isWhitespace(str.charAt(i)) == false)) {
                return false;
            }
        }
        return true;
    }

    public static boolean isNotBlank(String str) {
        return !isBlank(str);
    }

    public abstract String getStyle();

    public abstract String getFont();

    public abstract String getStyleClass();

    public abstract String getBackground();

    public abstract String getWidth();

    public abstract String getHeight();

    public abstract String getId();

    public abstract String getBgcolor();

}
